
$(function() {
	
	$('#rate').val(exchange);	
	_rmb();
	
	$('#amount').change(function() {
		var s = $(this).val();
		if (s != null && s != '-')　{
			_rmb();
		}		
	});
	
	$('#rate').change(function() {
		var s = $(this).val();
		if (s != null && s != '-')　{
			_rmb();
		}		
	});
	
	$('#invoice').datepicker(_date1_option);
	$('#date').datepicker(_date1_option);
	
	$('#currency').change(function() {
		var s = $(this).val();
		if (s != null && s != '-')　{
			currency = s;
			
			var body = { };
			body.currency = s;
			$.post('finance.php?do=Finance.ajax_exchange', body, function(s) {
				exchange = s;
				$('#rate').val(s);
			});
		}
	});
	
	$('#percent_t').change(function() {
		var s = $(this).val();
		if (s != null && s != '-')　{
			// $('#amount').val(s);
			_amount(s);
		}
	});
	
	$("input[id='engineer']:visible").autocomplete(Test.emp);
	
	$('textarea').css("width", 400);
});

function _rmb() {
	var a = $("#amount").val();
	var b = $('#rate').val();
	
	var rmb = fxmul(a, b);	
	$('#rmb').val(rmb);
}

function _amount(percent) {
	var a = $("#total").val();
	
	$("#amount").val(a*percent);
	
	_rmb();
}
